module.exports = function ($scope, toaster, $modalInstance, $resource, group_rule) {

    $scope.title = '';

    $scope.ok = function(){
        if(!$scope.title){
            toaster.warning({'title': '', 'body': '请添写标题'});
            return;
        }
        if($scope.title.length > 6){
            toaster.warning({'title': '', 'body': '标题过长, 请限制在6个字以内'});
            return;
        }
        var para = {
            'title': $scope.title,
            'context': group_rule
        }
        $resource('/api/as/tc/countfixed/create', {}, {}).save(para, function (res) {
            if (res.errcode === 0) {
                toaster.success({'title': '', 'body': '添加成功'});
                $modalInstance.close(group_rule);
            } else {
                toaster.error({'title': '', 'body': '添加失败'});
            }
        });
    }

    //关闭
    $scope.cancel = function () {
        $modalInstance.dismiss('cancel');
    };


};